import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../home.vue'
Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    redirect: '/title1/system',
  },
  // 菜单1
  {
    path: '/title1',
    component:()=>import('../title1/title1.vue'),
    children: [
      {
        path: 'system',
        name: 'system',
        component:()=>import('../page/system.vue')
      },
      {
        path: 'option',
        name: 'option',
        component:()=>import('../page/option.vue')
      },
      {
        path: 'table21',
        name: 'table21',
        component:()=>import('../page/table/table21.vue')
      },
      {
        path: 'table22',
        name: 'table22',
        component:()=>import('../page/table/table22.vue')
      },
      {
        path: 'table23',
        name: 'table23',
        component:()=>import('../page/table/table23.vue')
      },
      {
        path: 'table221',
        name: 'table221',
        component:()=>import('../page/table/table221.vue')
      },
      {
        path: 'table222',
        name: 'table222',
        component:()=>import('../page/table/table222.vue')
      },
      {
        path: 'icon',
        name: 'icon',
        component:()=>import('../page/icon.vue')
      },
      {
        path: 'component',
        name: 'component',
        component:()=>import('../page/component.vue')
      },
      {
        path: 'error',
        name: 'error',
        component:()=>import('../page/error.vue')
      },
      {
        path: 'upload',
        name: 'upload',
        component:()=>import('../page/handle/handle21.vue')
      },
      {
        path: 'congratulation',
        name: 'congratulation',
        component:()=>import('../page/congratulation.vue')
      }
    ],
    beforeEnter: (to, from, next) => { 
      console.log('beforeEnter');
      next()
    }
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../page/login.vue')
  },
  // 其他路由导航咯
  // 菜单2
  {
    path: '/title2',
    component:()=>import('../title2/title2.vue'),
    children: [
      {
        path: '2-menu1',
        name: 'Menu2_1',
        component:()=>import('../title2/title2-menu1.vue')
      },
      {
        path: '2-menu2',
        name: 'Menu2_2',
        component:()=>import('../title2/title2-menu2.vue')
      }
    ]
    
  },
  // 菜单3
  {
    path: '/title3',
    component: () => import('../title3/title3.vue'),
    children: [
      {
        path: '3-menu1',
        name: 'Menu3_1',
        component:()=>import('../title3/title3-menu1.vue')
      },
      {
        path: '3-menu2',
        name: 'Menu3_2',
        component:()=>import('../title3/title3-menu2.vue')
      }
    ]
  },
 
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => { 
  console.log('beforeEach');
  next()
})
router.afterEach((to, from) => { 
  console.log('afterEach');
  console.log(to);
  console.log(from);
})


export default router
